package com.tfjybj.itoo.teach.provider.facade;

import com.github.pagehelper.PageInfo;
import com.tfjybj.itoo.teach.FacadeApi.BuildingApi;
import com.tfjybj.itoo.teach.entity.BuildingEntity;
import com.tfjybj.itoo.teach.provider.service.BuildingService;
import org.apache.dubbo.config.annotation.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
@org.springframework.stereotype.Service
public class BuildingFacade implements BuildingApi {
    @Resource
    BuildingService buildingService;
    /**
     * 添加
     *
     * @param buildingEntity BuildingEntity
     * @return 添加的结果
     * @author 智雪艳
     * @since 2.0.0 2019/05/23 19:19
     */
    @Override
    public boolean create(BuildingEntity buildingEntity) {
        return buildingService.save(buildingEntity);
    }

    /**
     * 删除
     *
     * @param id 主键id
     * @return ItooResult 是否删除成功
     * @author 智雪艳
     * @since 2.0.0 2019/05/23 10:35:56
     */
    @Override
    public boolean delete(String id) {
       return buildingService.removeById(id);
    }

    /**
     * 批量删除
     *
     * @param ids ids
     * @return ItooResult 批量删除是否成功结果
     * @author 智雪艳
     * @since 2.0.0 2019/05/23 10:35:56
     */
    @Override
    public boolean deleteByIds(List<String> ids) {
        return buildingService.removeByIds(ids);
    }

    /**
     * 修改
     *
     * @param buildingEntity BuildingEntity
     * @return 修改后的结果
     * @author 智雪艳
     * @since 2.0.0 2019/05/23 10:35:56
     */
    @Override
    public boolean modify(BuildingEntity buildingEntity) {
       return buildingService.updateById(buildingEntity);
    }

    /**
     * 根据id查找Building
     *
     * @param id 主键id
     * @author 智雪艳
     * @since 2.0.0 2019/05/23 10:35:56
     */
    @Override
    public BuildingEntity findById(String id) {
        BuildingEntity buildingEntity = buildingService.getById(id);
        return buildingEntity;
    }
    /**
     * 分页查询所有Building
     *
     * @param pageNo   页码
     * @param pageSize 每页条数
     * @author 智雪艳
     * @since 2.0.0 2019/05/23 10:35:56
     */
    @Override
    public PageInfo<BuildingEntity> queryPageAll(Integer pageNo, Integer pageSize) {
        PageInfo<BuildingEntity> buildings = buildingService.queryPageAll(pageNo, pageSize);
        return buildings;
    }

    /**
     * 根据建筑名称模糊查询building
     *
     * @param name     建筑名称
     * @param pageNo   页码
     * @param pageSize 页数
     * @return 模糊查询的building
     * @author 智雪艳
     * @since 2.0.0 2019/05/2310:35:56
     */
    @Override
    public PageInfo<BuildingEntity> queryBuildingByLikeName(String name, Integer pageNo, Integer pageSize) {
        PageInfo<BuildingEntity> buildingList = buildingService.queryByLikeName(name, pageNo, pageSize);
        return buildingList;
    }

    /**
     * 根据id查找Building信息包含校区
     *
     * @return buildingEntity
     * @author 智雪艳
     * @since 2.0.0 2019/05/23 10:35:56
     */
    @Override
    public List<BuildingEntity> findBuilding() {
        return buildingService.findBuilding();
    }

}
